/*-
 *  Copyright (C) 2011 Peter Baldwin   
 *  
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.peterbaldwin.vlcremote.intent;

import org.peterbaldwin.vlcremote.model.Status;

import android.content.Intent;
import android.graphics.Bitmap;

public final class Intents {

    /**
     * Plays a media URI with VLC (usually streaming audio/video).
     * <p>
     * For example, {@code http://www.example.com/video.mp4}
     */
    public static final String ACTION_VIEW = "org.peterbaldwin.vlcremote.intent.action.VIEW";

    /**
     * Plays a browse URI (local file).
     * <p>
     * For example,
     * {@code http://mediaserver/requests/browse.xml?dir=...&file=...}
     */
    public static final String ACTION_PLAY = "org.peterbaldwin.vlcremote.intent.action.PLAY";

    /**
     * Streams a media file.
     */
    public static final String ACTION_STREAM = "org.peterbaldwin.vlcremote.intent.action.STREAM";

    /**
     * Enqueues a browse URI (local file).
     * <p>
     * For example,
     * {@code http://mediaserver/requests/browse.xml?dir=...&file=...}
     */
    public static final String ACTION_ENQUEUE = "org.peterbaldwin.vlcremote.intent.action.ENQUEUE";

    public static final String ACTION_MANUAL_APPWIDGET_UPDATE = "org.peterbaldwin.vlcremote.intent.action.MANUAL_APPWIDGET_UPDATE";

    public static final String ACTION_STATUS = "org.peterbaldwin.vlcremote.intent.action.STATUS";
    public static final String ACTION_PLAYLIST = "org.peterbaldwin.vlcremote.intent.action.PLAYLIST";
    public static final String ACTION_ART = "org.peterbaldwin.vlcremote.intent.action.ART";
    public static final String ACTION_ERROR = "org.peterbaldwin.vlcremote.intent.action.ERROR";

    public static final String EXTRA_STATUS = "org.peterbaldwin.vlcremote.intent.extra.STATUS";
    public static final String EXTRA_PLAYLIST = "org.peterbaldwin.vlcremote.intent.extra.PLAYLIST";
    public static final String EXTRA_BITMAP = "org.peterbaldwin.vlcremote.intent.extra.BITMAP";
    public static final String EXTRA_THROWABLE = "org.peterbaldwin.vlcremote.intent.extra.THROWABLE";
    public static final String EXTRA_FLAGS = "org.peterbaldwin.vlcremote.intent.extra.FLAGS";

    public static final String ACTION_REMOTE_VIEW = "org.openintents.remote.intent.action.VIEW";
    public static final String EXTRA_REMOTE_HOST = "org.openintents.remote.intent.extra.HOST";
    public static final String EXTRA_REMOTE_PORT = "org.openintents.remote.intent.extra.PORT";

    /**
     * Indicates if the command was generated by the user or programmatically.
     * <p>
     * This value is echoed back in the broadcast response.
     * <p>
     * The value can be used to determine whether or not it is appropriate to
     * display an error message to the user.
     */
    public static final int FLAG_PROGRAMMATIC = 1 << 0;

    /**
     * Instructs the service to only run the command if the media is playing.
     */
    public static final int FLAG_ONLY_IF_PLAYING = 1 << 1;

    /**
     * Instructs the service to only run the command if the media is paused.
     */
    public static final int FLAG_ONLY_IF_PAUSED = 1 << 2;

    /**
     * Instructs the service to call {@link VLC#setResumeOnIdle()} if and only
     * if the command is executed successfully.
     */
    public static final int FLAG_SET_RESUME_ON_IDLE = 1 << 3;

    public static Intent status(Status status) {
        Intent intent = new Intent(ACTION_STATUS);
        intent.putExtra(EXTRA_STATUS, status);
        return intent;
    }

    public static Intent art(Bitmap bitmap) {
        Intent intent = new Intent(ACTION_ART);
        intent.putExtra(EXTRA_BITMAP, bitmap);
        return intent;
    }

    public static Intent error(Throwable t) {
        Intent intent = new Intent(ACTION_ERROR);
        intent.putExtra(EXTRA_THROWABLE, t);
        return intent;
    }

    private Intents() {
    }
}
